const KoaRouter = require('koa-router');
const CONFIG = require('../../../config/index');
const UserlModel = require('../../../models/User');
const jwt = require('jsonwebtoken');

let Router = new KoaRouter()

Router.post('/addUser', async (ctx) => {
    //     await new UserlModel({
    //         userName:'wp0214',
    //         password:'wangpeng'
    //     }).save((err,doc) => {
    //         if(err) throw err;
    //         console.log(doc);
    //     })
    // 解析token
    let token = ctx.header.authorization
    let payload = await jwt.verify(token.split(' ')[1], CONFIG.secret);
    console.log(payload);
    ctx.body = {
        code: 0,
        data: payload
    }
})


module.exports = Router.routes();